/****************************************
File: planets.cpp

This file is part of Stellar

This program shows a fictional solar system and
provides several methods of interactions.

Copyright (C) 2001 David Stibbe (dstibbe@gmail.com)
                     and Gerrit Jan Jansen

Stellar is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
****************************************/

#include "planets.h"

model*	planetCPPmodel_list [MAX_MODELS];
	float moonTran[12][3]=
	{{1,2,2},
	{2,1,1},
    {3,2,-4},
	{3,-3,-3},
    {1,2,-3},
	{1,1,-1},
    {-1,-2,-1},
    {-1,-2,2},
	{-1,2,2},
	{1,-2,-2},
	{3,-2,1}};

/****************************************************************
 *						PLANETS									*
 ****************************************************************/

void load_ModelList(model* model_list){
      planetCPPmodel_list[0]=model_list;
}

//SUN
void createSun(){
	float			rotation[3];
	float			translation[3];
	float			color[3];
	float			speed;
	float			size;

	int				numberOfMoons;

	planet_data*	pData;
	moon*			planet_moons[MAX_MOONS];
	model*			shape;

	shape=planetCPPmodel_list[0];
	numberOfMoons=0;
	speed=0;
	size=4;

	fillMf3(rotation,0,0,0);
	fillMf3(translation,0,0,0);
	fillMf3(color,1.0,1.0,0.0);

	pData=     cPlanet_data(	rotation,
							    translation,
							    color,
							    speed,
								size,
							    numberOfMoons,
								planet_moons,
								shape,
								"Sun");
	createPlanet(pData);
}

//Mercurius
void createMercurius(){
	float			rotation[3];
	float			translation[3];
	float			color[3];
	float			speed;
	float			size;

	int				numberOfMoons;

	planet_data*	pData;
	moon*			planet_moons[MAX_MOONS];
	model*			shape;

	shape=planetCPPmodel_list[0];
	numberOfMoons=0;
	speed=10;
	size=0.4;


	fillMf3(translation,1,3,3);
	rotationNormal(translation,rotation);
	fillMf3(color,1.0,0.7,0.0);

	pData=     cPlanet_data(	rotation,
							    translation,
							    color,
							    speed,
								size,
							    numberOfMoons,
								planet_moons,
								shape,
								"Mercurius");
	createPlanet(pData);
}


//Venus
void createVenus(){
	float			rotation[3];
	float			translation[3];
	float			color[3];
	float			speed;
	float			size;

	int				numberOfMoons;

	planet_data*	pData;
	moon*			planet_moons[MAX_MOONS];
	model*			shape;

	shape=planetCPPmodel_list[0];
	numberOfMoons=0;
	speed=2;
	size=0.8;

	fillMf3(translation,6,2,-5);
	rotationNormal(translation,rotation);
	fillMf3(color,0.7,1,0);

	pData=     cPlanet_data(	rotation,
							    translation,
							    color,
							    speed,
								size,
							    numberOfMoons,
								planet_moons,
								shape,
								"Venus");
	createPlanet(pData);
}

//Earth
void createEarth(){
	float			rotation[3];
	float			translation[3];
	float			color[3];
	float			speed;
	float			size;

	int				numberOfMoons;

	moon*			planet_moons[MAX_MOONS];
	planet_data*	pData;
	moon_data*		mData;
	model*			shape;

	//Moon
	speed=9;
	size=0.2;
	shape=planetCPPmodel_list[0];

    fillMf3(translation,1,1,2);
	rotationNormal(translation,rotation);
	fillMf3(color,0.1,0.1,0.4);
	mData=			cMoon_data(	rotation,
								translation,
								color,
								speed,
								size,
								shape );

	planet_moons[0]=createMoon(mData);


    //Earth
	shape=planetCPPmodel_list[0];
	numberOfMoons=1;
	speed=2;
	size=0.6;

	fillMf3(translation,4,4,8);
	rotationNormal(translation,rotation);
	fillMf3(color,0,0,1);

	pData=     cPlanet_data(	rotation,
							    translation,
							    color,
							    speed,
								size,
							    numberOfMoons,
								planet_moons,
								shape,
								"Earth");
	createPlanet(pData);
}

//Mars

void createMars(){
	float			rotation[3];
	float			translation[3];
	float			color[3];
	float			speed;
	float			size;

	int				numberOfMoons;

	moon*			planet_moons[MAX_MOONS];
	planet_data*	pData;
	moon_data*		mData;
	model*			shape;

	//Moon1 Mars
	speed=2;
	size=0.15;
	shape=planetCPPmodel_list[0];

    fillMf3(translation,0.2,0.2,-0.6);
	rotationNormal(translation,rotation);
	fillMf3(color,0,1,0);
	mData=			cMoon_data(	rotation,
								translation,
								color,
								speed,
								size,
								shape );

	planet_moons[0]=createMoon(mData);

	//Moon2 Mars
	speed=1;
	size=0.14;

    fillMf3(translation,0.2,0.2,0.6);
	rotationNormal(translation,rotation);
	fillMf3(color,0.9,0.7,1);
	mData=			cMoon_data(	rotation,
								translation,
								color,
								speed,
								size,
								shape );

	planet_moons[1]=createMoon(mData);

	//Mars
	shape=planetCPPmodel_list[0];
	numberOfMoons=2;
	speed=1;
	size=0.5;

	fillMf3(translation,6,6,4);
	rotationNormal(translation,rotation);
	fillMf3(color,1,0,0);

	pData=     cPlanet_data(	rotation,
							    translation,
							    color,
							    speed,
								size,
							    numberOfMoons,
								planet_moons,
								shape,
								"Mars");
	createPlanet(pData);
}



//Jupiter
void createJupiter(){
	float			rotation[3];
	float*			translation;
	float			color[3];
	float			moon_trans[3];
	float			speed;
	float			size;


	int				numberOfMoons;
	int				count;


	moon*			planet_moons[MAX_MOONS];
	planet_data*	pData;
	moon_data*		mData;
	model*			shape;

	shape=planetCPPmodel_list[0];
	speed=2;
	size=0.3;
	for(count=1;count<=12;count++){
		//Moons Jupiter
		//moonTrans(count,translation);
		translation=moonTran[count];
		rotationNormal(translation,rotation);
		fillMf3(color,0,1,0);
		mData=		cMoon_data(	rotation,
								translation,
								color,
								speed,
								size,
								shape );


		planet_moons[count-1]=createMoon(mData);
	}
	//Jupiter
	shape=planetCPPmodel_list[0];
	numberOfMoons=12;
	speed=0.5;
	size=2;

	fillMf3(translation,10,5,5);
	rotationNormal(translation,rotation);
	fillMf3(color,0.8,0.7,1.0);
	pData=     cPlanet_data(	rotation,
							    translation,
							    color,
							    speed,
								size,
							    numberOfMoons,
								planet_moons,
								shape,
								"Jupiter");
	createPlanet(pData);
}

void createSaturnus(){
	float			rotation[3];
	float*			translation;
	float			color[3];
	float			moon_trans[3];
	float			speed;
	float			size;

	int				numberOfMoons;
	int				count;


	moon*			planet_moons[MAX_MOONS];
	planet_data*	pData;
	moon_data*		mData;
	model*			shape;

	shape=planetCPPmodel_list[0];
	speed=1;
	size=0.2;

	for(count=1;count<=8;count++){
		//Moons Saturn
		//moonTrans(count,translation);
		translation=moonTran[count];
		rotationNormal(translation,rotation);
		fillMf3(color,0,1,0);
		mData=		cMoon_data(	rotation,
								translation,
								color,
								speed,
								size,
								shape );


		planet_moons[count-1]=createMoon(mData);
	}

	//Saturnus
	shape=planetCPPmodel_list[0];
	numberOfMoons=8;
	speed=0.7;
	size=2.1;

	fillMf3(translation,12,7,4);
	rotationNormal(translation,rotation);
	fillMf3(color,0.8,0.7,0);
	pData=     cPlanet_data(	rotation,
							    translation,
							    color,
							    speed,
								size,
							    numberOfMoons,
								planet_moons,
								shape,
								"Saturnus");
	createPlanet(pData);
}

void createUranus(){
	float			rotation[3];
	float*			translation;
	float			color[3];
	float			moon_trans[3];
	float			speed;
	float			size;

	int				numberOfMoons;
	int				count;


	moon*			planet_moons[MAX_MOONS];
	planet_data*	pData;
	moon_data*		mData;
	model*			shape;

	shape=planetCPPmodel_list[0];
	speed=1;
	size=0.15;
	for(count=1;count<=3;count++){
		//Moons Uranus
		//moonTrans(count,translation);
		translation=moonTran[count];
		rotationNormal(translation,rotation);
		fillMf3(color,0,1,0.9);
		mData=		cMoon_data(	rotation,
								translation,
								color,
								speed,
								size,
								shape );


		planet_moons[count-1]=createMoon(mData);
	}
	//Uranus
	shape=planetCPPmodel_list[0];
	numberOfMoons=3;
	speed=0.4;
	size=0.9;

	fillMf3(translation,12,7,4);
	rotationNormal(translation,rotation);
	fillMf3(color,0.9,0.9,0.9);
	pData=     cPlanet_data(	rotation,
							    translation,
							    color,
							    speed,
								size,
							    numberOfMoons,
								planet_moons,
								shape,
								"Uranus");
	createPlanet(pData);
}


void createNeptunus(){
	float			rotation[3];
	float			translation[3];
	float			color[3];
	float			moon_trans[3];
	float			speed;
	float			size;

	int				numberOfMoons;

	moon*			planet_moons[MAX_MOONS];
	planet_data*	pData;
	moon_data*		mData;
	model*			shape;

	shape=planetCPPmodel_list[0];
	speed=1;
	size=0.2;

	//Moon Neptunus
    fillMf3(translation,2,2,1);
	rotationNormal(translation,rotation);
	fillMf3(color,0,1,0);
	mData=		cMoon_data(	rotation,
							translation,
							color,
							speed,
							size,
							shape );
	planet_moons[0]=createMoon(mData);

	//Neptunus
	shape=planetCPPmodel_list[0];
	numberOfMoons=1;
	speed=0.9;
	size=1;

	fillMf3(translation,13,7,5);
	rotationNormal(translation,rotation);
	fillMf3(color,0.6,0.7,0.8);
	pData=     cPlanet_data(	rotation,
							    translation,
							    color,
							    speed,
								size,
							    numberOfMoons,
								planet_moons,
								shape,
								"Neptunus");
	createPlanet(pData);
}
void createPluto(){
	float			rotation[3];
	float			translation[3];
	float			color[3];
	float			moon_trans[3];
	float			speed;
	float			size;

	int				numberOfMoons;
	int				count;


	moon*			planet_moons[MAX_MOONS];
	planet_data*	pData;
	moon_data*		mData;
	model*			shape;

	shape=planetCPPmodel_list[0];
	speed=1;
	size=0.2;

	//Pluto
	shape=planetCPPmodel_list[0];
	numberOfMoons=0;
	speed=0.9;
	size=.5;

	fillMf3(translation,13,8,8);
	rotationNormal(translation,rotation);
	fillMf3(color,0.8,0.7,0);
	pData=     cPlanet_data(	rotation,
							    translation,
							    color,
							    speed,
								size,
							    numberOfMoons,
								planet_moons,
								shape,
								"Pluto");
	createPlanet(pData);

}
